<template>
  <div ref="barChart" class="barChart" />
</template>

<script>
import * as echarts from 'echarts'
export default {
  mounted() {
    const barChart = echarts.init(this.$refs.barChart)
    const option = {
      xAxis: {
        show: false,
        // type: 'category',
        min: 0,
        max: 100
      },
      yAxis: {
        show: false,
        type: 'category'
      },
      grid: {
        left: 0,
        right: 0,
        bottom: 0,
        top: 0
      },
      series: [
        {
          data: [78],
          type: 'bar',
          color: 'yellowgreen',
          //   柱状图宽度
          barWidth: 10,
          //   背景色设置
          showBackground: true,
          backgroundStyle: {
            color: '#eee'
          },
          //   文本标签
          label: {
            show: true,
            formatter: '|',
            color: 'red',
            position: 'right'
          }
        }
      ]
    }
    barChart.setOption(option)
  }
}
</script>

<style scoped lang="scss">
.barChart {
  width: 100%;
  height: 100%;
}
</style>
